import { Injectable } from '@nestjs/common';
import { InjectRedis } from '@nestjs-modules/ioredis';
import Redis from 'ioredis';
import { DataSource } from 'typeorm';
@Injectable()
export class AppService {
  constructor(
    @InjectRedis() private readonly redis: Redis,
    private readonly dataSource: DataSource,
  ) {}

  async setKey(key: string, value: string): Promise<void> {
    await this.redis.set(key, value);
  }

  async getKey(key: string): Promise<string | null> {
    return this.redis.get(key);
  }

  onModuleInit() {
    console.log('NODE_ENV:' + process.env.NODE_ENV);
    console.log('DATABASE_URL:' + process.env.DATABASE_URL);
    console.log('SERVE_PORT:' + process.env.SERVE_PORT);
  }
}
